/**
* CalendarSeeker 
* This program prints out the day of the week for a given day
* Following algorithm is realized in the program
* a = (14 - month) / 12
* y = year - a
* m = month + 12 * a - 2
* dayOfWeek = (7000 + (day + y + y / 4 - y / 100 + y / 400 + (31 * m) / 12)) mod 7
* @author Maksym Ryumin
*/

import java.util.*;
import java.util.ArrayList; 
import static java.lang.Math.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class CalendarSeeker{

	public static void main(String[] args) {  
        System.out.print("Please, enter a date as in the following format dd/mm/yyyy \n");
				  
		Scanner in = new Scanner(System.in);
		
		String userDate = in.nextLine();
		
		String pattern = "dd/mm/yyyy";
        
		SimpleDateFormat format = new SimpleDateFormat(pattern);
		
		boolean wrongDate = false;
		
		
		try {
            Date date = format.parse(userDate);
        } catch (ParseException e) {
              wrongDate = true;
			  System.out.print("Wrong date format \n");
          }    		
		
		if(wrongDate == false){
		    String[] userStringDateArray;
					
			userStringDateArray = userDate.split("/");
			
			int day = Integer.parseInt(userStringDateArray[0]);
			int month = Integer.parseInt(userStringDateArray[1]);
			int year = Integer.parseInt(userStringDateArray[2]);
			
			//Initialize constants for the algorithm
			int monthsInYear = 12;
			int daysInMonth = 31;
			int daysInWeek = 7;
			int const_14 = 14;
			int const_2 = 2;
			int const_7000 = 7000;
			int const_4 = 4;
			int const_100 = 100;
			int const_400 = 400;
			
			
			int shift = (const_14 - month) / monthsInYear;
			int shiftYear = year - shift;
            int shiftMonth = month + monthsInYear * shift - const_2;			
			int numberOfDay = (const_7000 + (day + shiftYear + shiftYear / const_4 - shiftYear / const_100 + shiftYear / const_400 + (daysInMonth * shiftMonth) / monthsInYear)) % daysInWeek;
			
			String dayInWeek = "SUNDAY";
			
			switch (numberOfDay){
				case 1: dayInWeek = "MONDAY";
				        break;
				
				case 2:	dayInWeek = "TUESDAY";
				        break;
				
				case 3:	dayInWeek = "WEDNESDAY";
				        break;
				
				case 4:	dayInWeek = "THURSDAY";
				        break;
				
				case 5:	dayInWeek = "FRIDAY";
				        break;
				
				case 6:	dayInWeek = "SATURDAY";
				        break;
				
				default: break;
			}
            
			System.out.println("The day is " + dayInWeek);	
		}
    }		
	
	}